﻿using JzSport.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JzSport.Api
{
    class ChangePassword4ForgottenPasswordAction : PostAction<Params.ChangePassword4ForgottenPasswordParams,
        Results.ChangePassword4ForgottenPasswordResult>
    {
        protected override ActionResult<Results.ChangePassword4ForgottenPasswordResult> OnExecute(ActionContext context, SysParameters sysParameters,
            Params.ChangePassword4ForgottenPasswordParams opParams)
        {
            ServiceResult<Account> serviceResult = new AccountService().ChangePassword4ForgottenPassword(
                opParams.Phone,
                opParams.Password,
                opParams.Verifycode);

            Results.ChangePassword4ForgottenPasswordResult actionResult = new Results.ChangePassword4ForgottenPasswordResult();

            if (serviceResult.ErrorCode == ErrorCode.NoError)
            {
                return new ActionResult<Results.ChangePassword4ForgottenPasswordResult>(true, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
            }
            return new ActionResult<Results.ChangePassword4ForgottenPasswordResult>(false, serviceResult.ErrorCode,
                    ErrorCode.ToString(serviceResult.ErrorCode), actionResult);
        }
    }
}
